﻿@model planerka.DataAccess.Models.task
@using planerka.DataAccess.Models;
@using planerka.DataAccess.DataService;
@{
    bool rightsEdit = Model.rightsEditDelete;
    
        
}


@if (rightsEdit)
{
<table id="paymentsTable">
            <tr>
                <th style="width: 100px;">
                    Сумма
                </th>
                <th style="width: 100px;">
                    Дата
                </th>
                <th style="width: 210px;">
                    Комментарий
                </th>
                <th style="width: 60px;">
                    &nbsp;
                </th>

            </tr>
            @{
                List<payment> payments = new PaymentService().getTaskPayments(Model.ID);
             }
             
                @foreach (var paymentItem in payments)
	            {
                
                    <tr style="background-color: White;">
                        <td>
                            @(paymentItem.sumIn != 0 ? "+ " + paymentItem.sumIn : "- " + paymentItem.sumOut) 
                        </td>
                        <td>
                            @(paymentItem.timestamp != null ? ((DateTime)paymentItem.timestamp).ToShortDateString() : "")
                        </td>
                        <td>
                            @paymentItem.comment
                        </td>
                        <td>
                            @Ajax.ActionLink(" ", "taskDetails", "tm", new { confirmButton = "удалить", payment_ID = paymentItem.ID },
                          new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "updateMe", OnSuccess = "loadScripts" }, new { @class = "rollover_del" })
                        </td>
                    </tr>
                }

            <tr>
                <td>
                    @Html.TextBoxFor(model => model.addPayment, new { style="width: 86px !important;" })
                    
                </td>
                <td>
                    @Html.TextBox("addPaymentDate", Model.addPaymentDateString, new { @class = "dateField", style = "width: 86px !important;" })
                </td>
                <td>
                    @Html.TextBoxFor(model => model.addPaymentComment, new { style = "width: 206px;" })
                </td>
                <td>
                    <input id="addPaymentButton" type="submit" value="Внести" name="confirmButton" />
                </td>
            </tr>
         </table>
        @Html.ValidationMessageFor(model => model.addPayment, "Введите число")
}
else
{
    @:только просмотр
}